package com.demo.servlet;

import com.demo.bean.Person;
import com.demo.bean.Person1;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author WuLiangHang
 */
@WebServlet("/listener1.do")
public class ListenerServlet1 extends BaseServlet {
    public String addPerson(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        Person1 p = new Person1("zhangsan", 23, "male");
        req.getSession().setAttribute("person", p);
        return "/index.jsp";
    }

    public String removePerson(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.getSession().removeAttribute("person");
        return "/index.jsp";
    }
}
